package com.kandinfo.survey.common.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.kandinfo.base.common.constant.ResultCode;
import com.kandinfo.base.common.dto.ResultDto;
import com.kandinfo.base.common.dto.ResultDtoFactory;
import com.kandinfo.survey.common.dto.QuestionOptionDto;
import com.kandinfo.survey.common.service.QuestionOptionService;

/**
 * 问卷明细Controller, add on 11/30/2016
 * 
 * @author Patrick-chenzp
 */
@Controller
@RequestMapping(value = "/questionoption")
public class QuestionOptionController {

    @Autowired
    private QuestionOptionService questionOptionService;

    /**
     * 保存option
     */
    @RequestMapping(value = "/save", method = RequestMethod.POST)
    @ResponseBody
    public ResultDto save(@RequestParam(value = "options[]") List<QuestionOptionDto> options) {
        if (questionOptionService.saveOption(options)) {
            return ResultDtoFactory.createResult(ResultCode.SUCCESS, "保存成功！");
        }
        return ResultDtoFactory.createResult(ResultCode.ERROR, "option保存失败！");
    }
}
